export function uploadFile(options) {
  options = options || {}
  let input = document.createElement('input')
  input.setAttribute('type', 'file')
  if (options.accept) {
    input.setAttribute('accept', options.accept.toLowerCase())
  }
  input.style.display = 'none'
  document.body.appendChild(input)
  return new Promise(resolve => {
    input.addEventListener('change', e => {
      let file = e.target.files[0]
      resolve(file)
    })
    input.click()
    document.body.removeChild(input)
  })
}


export const getDownloadTemplate = (fileName, name= '模板')=>{
  const url = `https://supply.zhongyimotor.com/upload/excel/${fileName}`
  const a = document.createElement('a')
  a.href = url
  a.download = name // 下载后文件名
  a.style.display = 'none'
  document.body.appendChild(a)
  a.click() // 点击下载
  document.body.removeChild(a) // 下载
}